package here.android.herehelper;

import here.android.data.GLOBALDATA;

import java.io.IOException;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

public class hereService extends Service
{
	private hereSocketServer	server	= null;

	@Override
	public IBinder onBind(Intent intent)
	{
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.app.Service#onCreate()
	 */
	@Override
	public void onCreate()
	{
		super.onCreate( );

		if ( null == server )
		{
			try
			{
				server = new hereSocketServer( );
				server.SetAppContext(GLOBALDATA.intentContext);

				new Thread(new Runnable( )
				{
					@Override
					public void run()
					{
						server.startServer( );
					}
				}).start( );
			}
			catch ( IOException e )
			{
				e.printStackTrace( );
			}
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.app.Service#onDestroy()
	 */
	@Override
	public void onDestroy()
	{
		super.onDestroy( );
		
		server.stopServer( );
	}

}
